package com.spa.interfaces.shop;

import com.spa.application.command.shop.MassagistAddCommand;
import com.spa.application.command.shop.MassagistDelCommand;
import com.spa.application.command.shop.MassagistEditCommand;
import com.spa.application.command.shop.MassagistEvaluateDelCommand;
import com.spa.application.dto.PageResult;
import com.spa.application.dto.shop.ActualMassagistInfoDTO;
import com.spa.application.dto.shop.MassagistBaseInfoDTO;
import com.spa.application.dto.shop.ShopMassagistCountDTO;
import com.spa.application.dto.shop.ShopMassagistDetailsDTO;
import com.spa.application.dto.shop.ShopMassagistEvaluateDTO;
import com.spa.application.dto.shop.ShopMassagistEvaluateStatisticsDTO;
import com.spa.application.query.PageQuery;
import com.spa.application.query.shop.MassagistListQuery;
import com.spa.application.query.shop.ShopMassagistDetailsQuery;
import com.spa.application.query.shop.ShopMassagistEvaluateQuery;
import com.spa.application.service.ShopApplicationService;
import com.spa.application.service.shop.ShopIndexService;
import com.spa.infrastructure.common.ResponseMessage;
import com.spa.interfaces.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/shop/index")
public class ShopMassagistController extends BaseController {

    @Autowired
    private ShopIndexService shopIndexService;

    @Autowired
    private ShopApplicationService shopApplicationService;

    @PostMapping("queryMassagistList")
    public ResponseMessage<PageResult<MassagistBaseInfoDTO>> queryMassagistList(@RequestBody MassagistListQuery query) {
        return responseHelper.success(shopIndexService.queryMassagistList(query));
    }

    @PostMapping("addMassagist")
    public ResponseMessage addMassagist(@Validated @RequestBody MassagistAddCommand command) {
        return shopIndexService.addMassagist(command);
    }

    @PostMapping("editMassagist")
    public ResponseMessage editMassagist(@Validated @RequestBody MassagistEditCommand command) {
        shopIndexService.editMassagist(command);
        return responseHelper.success();
    }

    @PostMapping("massagistInfoById")
    public ResponseMessage<ShopMassagistDetailsDTO> editMassagist(@RequestBody ShopMassagistDetailsQuery query) {
        return responseHelper.success(shopApplicationService.massagistInfoById(query));
    }

    @PostMapping("delMassagist")
    public ResponseMessage delMassagist(@RequestBody MassagistDelCommand command) {
        shopIndexService.delMassagist(command);
        return responseHelper.success();
    }

    @PostMapping("queryShopMassagistCount")
    public ResponseMessage<List<ShopMassagistCountDTO>> queryShopMassagistCount() {
        return responseHelper.success(shopApplicationService.shopMassagistCount());
    }

    @PostMapping("massagistEvaluateStatistics")
    public ResponseMessage<ShopMassagistEvaluateStatisticsDTO> massagistEvaluateStatistics() {
        return responseHelper.success(shopApplicationService.massagistEvaluateStatistics());
    }

    @PostMapping("massagistEvaluatePage")
    public ResponseMessage<PageResult<ShopMassagistEvaluateDTO>> massagistEvaluatePage(@Validated @RequestBody ShopMassagistEvaluateQuery query) {

        return responseHelper.success(shopApplicationService.massagistEvaluatePage(query));
    }

    @PostMapping("massagistEvaluateDel")
    public ResponseMessage massagistEvaluateDel(@Validated @RequestBody MassagistEvaluateDelCommand command) {
        if (shopApplicationService.massagistEvaluateDel(command)) {
            return responseHelper.success();
        }
        return responseHelper.fail();
    }

    @PostMapping("queryActualMassagistList")
    public ResponseMessage<PageResult<ActualMassagistInfoDTO>> queryActualMassagistList(@RequestBody PageQuery query) {
        return responseHelper.success(shopIndexService.queryActualMassagistList(query));
    }

}
